def fac(k):
    i=2
    t=1
    while i<=k:
        t *= i
        i += 1
    return t
def sum(n):
    s=0
    i=1
    while i<=n:
        s=s+fac(i)
        i+= 3
    return s
print('1!+4!+7!+....+50!=',sum(50))
